﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><!-- saved from url=(0014)about:internet -->
<html>
	<head>
		<title>环境</title>
        <script src="jquery.min.js" type="text/javascript"></script>
        <script type="text/javascript" src="http://api.map.baidu.com/api?v=1.3"></script>
        <link href="Stylesheet1.css" rel="Stylesheet" type="text/css" />
         <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> 
	</head>
	<body scroll="no" bgcolor="#121212">
	<div style="width:420px;height:370px;border:1px solid gray" id="container"></div>
<div><input name="environment" style="margin: 10px 5px 0px 0px; width: 50px; height: 25px; font-size: 12px; font-family: 微软雅黑;" type="button" value="环境" id="environment"  class="auto-style1" onclick="Select3();"></div>
</body>
</html>
<script type="text/javascript">
    var map = new BMap.Map("container");            // 创建Map实例
    var point = new BMap.Point(121.22, 31.48);    // 创建点坐标
    map.centerAndZoom(point, 15);                     // 初始化地图,设置中心点坐标和地图级别。
    map.addControl(new BMap.NavigationControl());
    map.addControl(new BMap.ScaleControl());
</script>
<script type="text/javascript">
    $(document).ready(function () {
        var environment = document.getElementById('environment').value;
        window.external.ClickEventEnv(environment);
        Addpoint();
    });
    function Select3() {
        var environment = document.getElementById('environment').value;
        window.external.ClickEventEnv(environment);
        alert(window.external.name);
        Addpoint();
    }
    function Addpoint() {
        var jsonconf = $.parseJSON(window.external.name);
        var points = [];
        map.clearOverlays();
        for (var i = 0; i < jsonconf.length; i++) {
            addMarker1(new BMap.Point(jsonconf[i].Longitude, jsonconf[i].Latitude), jsonconf[i].Name, jsonconf[i].Description);
            points.push(new BMap.Point(jsonconf[i].Longitude, jsonconf[i].Latitude));
        }
        map.setViewport(points);
    }
    function addMarker1(point1, text, description) {
        var marker = new BMap.Marker(point1);
        map.addOverlay(marker);
        var label = new BMap.Label(text, { offset: new BMap.Size(20, -10) });
        marker.setLabel(label);
        var sContent =
            "<div><h4 style='margin:0 0 5px 0;padding:0.2em 0'>" + text + "</h4>" +
            "<p style='margin:0;line-height:1.5;font-size:13px;text-indent:2em;width:200px;'>" + description + "</p>" +
            "</div>";

        var infoWindow = new BMap.InfoWindow(sContent);  // 创建信息窗口对象
        marker.addEventListener("click", function () {
            this.openInfoWindow(infoWindow);
            //图片加载完毕重绘infowindow
        });
    }
</script>